package cn.flant.cfg;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class MapConfigLoader extends ConfigLoader {
	@SuppressWarnings("unchecked")
	public Map<String, Object> loadConfig(Map<Object, Object> map) {
		Map<String, Object> config = new HashMap<String, Object>();
		for (Entry<Object, Object> entry : map.entrySet()) {
			String key = entry.getKey().toString();
			Object value = entry.getValue();
			if (value != null && value instanceof Map) {
				value = loadConfig((Map<Object, Object>) value);
			}
			if (isIgnoreCase) {
				key = key.toLowerCase();
			}
			config.put(key, value);
		}
		return config;
	}
}
